//
//  GRLocalizatonManager.m
//  Gree+
//
//  Created by world hello on 2017/5/31.
//  Copyright © 2017年 gree. All rights reserved.
//

#import "GRLocalizatonManager.h"

@implementation GRLocalizatonManager

/**
 获取本地化字串
 
 @param key 字段的健
 @return 字段的值
 */
+(NSString *)GRLocalizedString:(NSString *)key
{
    NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
    NSArray *allLanguages = [defaults objectForKey:@"AppleLanguages"];
    NSString *preferredLang = [allLanguages objectAtIndex:0];
    NSString *resource=[[NSBundle mainBundle]pathForResource:@"China" ofType:@"bundle"];
    NSString *path=@"";
    if ([preferredLang hasPrefix:@"zh-Hans"]) {
        path = [[NSBundle bundleWithPath:resource] pathForResource:@"zh-Hans" ofType:@"lproj"];
    }else{
        path =[[NSBundle bundleWithPath:resource] pathForResource:@"zh-Hans" ofType:@"lproj"];
    }
    NSBundle *languageBundle = [NSBundle bundleWithPath:path];
    return [languageBundle localizedStringForKey:key value:@"" table:nil];
}

@end
